﻿#include "cdisplayinfo.h"
#include <QScreen>
#include <QGuiApplication>
#include <QDebug>

namespace ss {
CDisplayInfo::CDisplayInfo()
{

}

void CDisplayInfo::ReadDisplayInfo()
{
    QList<QScreen*> screenList = QGuiApplication::screens();
    for (auto i = 0; i < screenList.size(); ++i)
    {
        m_vecDisplays.emplace_back(Display(
                   screenList.at(i)->name(),
                   screenList.at(i)->manufacturer(),
                   screenList.at(i)->model(),
                   screenList.at(i)->serialNumber(),
                   screenList.at(i)->geometry(),
                   screenList.at(i)->size()));
    }

#ifdef QT_DEBUG1
    for (auto iter = m_vecDisplays.begin(); iter != m_vecDisplays.end(); ++iter)
    {
        qDebug() << iter->name;
        qDebug() << iter->manufacturer;
        qDebug() << iter->model;
        qDebug() << iter->serialNumber;
        qDebug() << "left = " << iter->geometry.left() << ", "
                 << "top = " << iter->geometry.top() << ", "
                 << "bottom = " << iter->geometry.bottom() << ", "
                 << "right " << iter->geometry.right();

        qDebug() << "width = " << iter->size.width() << ", "
                 << "height = " << iter->size.height();

        qDebug() << "----------------------------------------------";
    }
#endif

}

const std::vector<Display> &CDisplayInfo::GetDisplays() const
{
    return m_vecDisplays;
}

}
